package com.atguigu.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value="/api/album/category")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {
	
	@Autowired
	private BaseCategoryService baseCategoryService;

	@Operation(summary = "获取专辑分类数据")
	@GetMapping("/getBaseCategoryList")
	public Result getBaseCategoryList(){
		//调用服务层的方法 查询所有数据并组成成一个Json结合并返回数据！将返回数据封装到categoryName categoryId categoryChild
		//将Json中的内容，转换为实体类！还可以使用Map来代替实体类！
		List<JSONObject> jsonObjectList = baseCategoryService.getBaseCategoryList();
		return Result.ok(jsonObjectList);

	}


}

